program q1103;
var
    i, j, l, m, s, e, ans:integer;
    map:array[0..10000] of integer;
begin
    assign(input, '');
    assign(output, '');
    reset(input);
    rewrite(output);

    readln(l, m);
    for i:=0 to l do
        map[i] := 1;

    for i:=1 to m do begin
        readln(s, e);
        for j:=s to e do
            map[j] := 0;
    end;

    ans := 0;
    for i:=0 to l do
        if (map[i] = 1) then inc(ans);

    writeln(ans);

    close(input);
    close(output);
end.
